package com.ruoyi.service.equipment.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.equipment.MesEquipmentMaintenance;
import com.ruoyi.mapper.equipment.MesEquipmentMaintenanceMapper;
import com.ruoyi.service.equipment.IMesEquipmentMaintenanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备维护记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@Service
public class MesEquipmentMaintenanceServiceImpl implements IMesEquipmentMaintenanceService
{
    @Autowired
    private MesEquipmentMaintenanceMapper mesEquipmentMaintenanceMapper;

    /**
     * 查询设备维护记录
     * 
     * @param maintenanceId 设备维护记录主键
     * @return 设备维护记录
     */
    @Override
    public MesEquipmentMaintenance selectMesEquipmentMaintenanceByMaintenanceId(Long maintenanceId)
    {
        return mesEquipmentMaintenanceMapper.selectMesEquipmentMaintenanceByMaintenanceId(maintenanceId);
    }

    /**
     * 查询设备维护记录列表
     * 
     * @param mesEquipmentMaintenance 设备维护记录
     * @return 设备维护记录
     */
    @Override
    public List<MesEquipmentMaintenance> selectMesEquipmentMaintenanceList(MesEquipmentMaintenance mesEquipmentMaintenance)
    {
        return mesEquipmentMaintenanceMapper.selectMesEquipmentMaintenanceList(mesEquipmentMaintenance);
    }

    /**
     * 根据设备ID查询维护记录列表
     * 
     * @param equipmentId 设备ID
     * @return 设备维护记录集合
     */
    @Override
    public List<MesEquipmentMaintenance> selectMaintenanceByEquipmentId(Long equipmentId)
    {
        return mesEquipmentMaintenanceMapper.selectMaintenanceByEquipmentId(equipmentId);
    }

    /**
     * 根据维护编号查询维护记录
     * 
     * @param maintenanceCode 维护编号
     * @return 设备维护记录
     */
    @Override
    public MesEquipmentMaintenance selectMaintenanceByCode(String maintenanceCode)
    {
        return mesEquipmentMaintenanceMapper.selectMaintenanceByCode(maintenanceCode);
    }

    /**
     * 校验维护编号是否唯一
     * 
     * @param maintenanceCode 维护编号
     * @return 结果
     */
    @Override
    public String checkMaintenanceCodeUnique(String maintenanceCode)
    {
        MesEquipmentMaintenance maintenance = mesEquipmentMaintenanceMapper.checkMaintenanceCodeUnique(maintenanceCode);
        if (StringUtils.isNotNull(maintenance))
        {
            return "1"; // 不唯一
        }
        return "0"; // 唯一
    }

    /**
     * 新增设备维护记录
     * 
     * @param mesEquipmentMaintenance 设备维护记录
     * @return 结果
     */
    @Override
    public int insertMesEquipmentMaintenance(MesEquipmentMaintenance mesEquipmentMaintenance)
    {
        return mesEquipmentMaintenanceMapper.insertMesEquipmentMaintenance(mesEquipmentMaintenance);
    }

    /**
     * 修改设备维护记录
     * 
     * @param mesEquipmentMaintenance 设备维护记录
     * @return 结果
     */
    @Override
    public int updateMesEquipmentMaintenance(MesEquipmentMaintenance mesEquipmentMaintenance)
    {
        return mesEquipmentMaintenanceMapper.updateMesEquipmentMaintenance(mesEquipmentMaintenance);
    }

    /**
     * 批量删除设备维护记录
     * 
     * @param maintenanceIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int deleteMesEquipmentMaintenanceByMaintenanceIds(Long[] maintenanceIds)
    {
        return mesEquipmentMaintenanceMapper.deleteMesEquipmentMaintenanceByMaintenanceIds(maintenanceIds);
    }

    /**
     * 删除设备维护记录信息
     * 
     * @param maintenanceId 设备维护记录主键
     * @return 结果
     */
    @Override
    public int deleteMesEquipmentMaintenanceByMaintenanceId(Long maintenanceId)
    {
        return mesEquipmentMaintenanceMapper.deleteMesEquipmentMaintenanceByMaintenanceId(maintenanceId);
    }
}